package com.woniuxy.aliyunoss.controller;

import com.woniuxy.aliyunoss.service.ImageService;
import com.woniuxy.commons.entity.Image;
import com.woniuxy.commons.utils.ResponseResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 雷珉
 * @date 2022年06月10日 15:35
 */
@RestController
@RequestMapping("/aliyunoss/image")
public class ImageController {

    @Resource
    private ImageService imageService;

    @GetMapping("/{module}/{relatedId}")
    public ResponseResult<List<Image>> findByModuleAndRelatedId(@PathVariable("module") String module, @PathVariable("relatedId") int relatedId){
        return imageService.findByModuleAndRelatedId(module,relatedId);
    }

    @PutMapping("/")
    public ResponseResult addOne(@RequestBody Image image){
        return imageService.addOne(image);
    }

    @DeleteMapping("/{id}")
    public ResponseResult deleteOne(@PathVariable("id") int id){
        return imageService.deleteOne(id);
    }

}

